package com.spx.usercenter.exception;

import com.spx.usercenter.common.ErrorCode;

/**
 * 自定义异常类
 *
 */
public class BusinessException extends RuntimeException {

    private final int code;
    private final String desicription;

    public BusinessException(String message, int code, String desicription) {
        super(message);
        this.code = code;
        this.desicription = desicription;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.desicription = errorCode.getDescription();
    }

    public BusinessException(ErrorCode errorCode, String desicription) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.desicription = desicription;
    }

    public int getCode() {
        return code;
    }

    public String getDesicription() {
        return desicription;
    }
}

